Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone write a test bench for this 4x16 register file in verilog `timescale 1ns / 1ns module regfile4x16a (input clk, input write, input [2:0]
Can someone write a test bench for this 4x16 register file in verilog `timescale 1ns / 1ns module regfile4x16a (input clk, input write, input [2:0] wrAddr, input [15:0] wrData, input [2:0] rdAddrA, output [15:0] rdDataA, input [2:0] rdAddrB, output [15:0] rdDataB); reg [15:0] reg0, reg1, reg2, reg3; assign rdDataA = rdAddrA == 0 ? reg0 : rdAddrA == 1 ? reg1 : rdAddrA == 2 ? reg2 : rdAddrA == 3 ? reg3 : 0; assign rdDataB = rdAddrB == 0 ? reg0 : rdAddrB == 1 ? reg1 : rdAddrB == 2 ? reg2 : rdAddrB == 3 ? reg3 : 0; always @(posedge clk) begin if (write) case (wrAddr) 0: begin reg0 <= wrData; end 1: begin reg1 <= wrData; end 2: begin reg2 <= wrData; end 3: begin reg3 <= wrData; end endcase // case (wrAddr) end // always @ (posedge clk) endmodule
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started