Question

Objective: Creating a register file (memory) using Verilog. The register file is made up of four registers and each register

3. Create a D flip-flop AD flip-flop holds 1 bit of data, and it only changes its data when the clock changes. We want a posi

so we will create them now. Enter the 2 to 4 line decoder. We will need two decoders in the final step of our modifications.

Put D first in the port list. As a general rule, outputs are always first The ports A and B are actually the address bits

Build the register file from the registers data in3:0 |data out[3:0] data in3:0 load data out[3:0 4-bit Reg out en write add

Objective: Creating a register file (memory) using Verilog. The register file is made up of four registers and each register holds one nibble (half a byte, i.e., four bits)
3. Create a D flip-flop AD flip-flop holds 1 bit of data, and it only changes its data when the clock changes. We want a positive edge triggered flip-flop. Design your Verilog D flip-flop,
so we will create them now. Enter the 2 to 4 line decoder. We will need two decoders in the final step of our modifications. design
Put D" first in the port list. As a general rule, outputs are always first The ports A" and B" are actually the address bits so combine them into one new port "A" that has two bits. Note you will have to change the port list, input line, and the assignments. Change the bit ordering of D" from "T0:3]"(big endian) to 3:01(little endian) to be consistent with the rest of the design
Build the register file from the registers data in3:0 |data out[3:0] data in3:0 load data out[3:0 4-bit Reg out en write add data in[3:0 load data out[3:0 write en 4-bit Reg out en data in[3:0 load data out[3:0 2 4-bit Reg out en read add |dat a in3:0 load data out[3:0 read en 4-bit Reg out en register file, like the diagram shown above Create a module to hold our /name: Register_File // desc: 4x4 register file date / by module Register_File(data_out,data_in,read_add, read_en,write_add, write_en); input input input output [3:0] data_out; [3:0] data_in [1:0] read_add, write_add; // read address and write address /data to write /read and write enable read_en,write_en; /data to read wire [3:0] read_sel,write_sel; //instantiate registers here dec2x4 Dec_Read (read_sel, read_en, read_add) dec2x4 Dec_Write (write_sel, write_en, write_add) //instantiate registers here Nibble_Reg Reg_®(data_out, data_in,write_sel[0], read_sel[0]); / finish making instances endmodule
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1)

//Register File
// First we are developing the 2 to 4 decoder

module dec2x4 (out1, enable, select);
input enable;
input [1:0] select;
output [3:0] out1;
reg [3:0] out1;

always @(enable, select)
begin
if (enable)
begin
case(select)
2'b00 : out1 = 4'b0001;
2'b01 : out1 = 4'b0010;
2'b10 : out1 = 4'b0100;
2'b11 : out1 = 4'b1000;
endcase
end
else
begin
out1 = 4'b0000;
end
end
  
endmodule

// The module for D flip flop is below

module DFF (Q, clk, D);
input clk;
input D;
output reg Q;

always @ (posedge clk)
begin
Q <= D;
end

endmodule

// We are now developing the 4 bit register to store the data based on load input

// and will give the output only on output enable (out_en)


module Nibble_reg (data_out, clk, data_in, load, out_en);
input clk;
input [3:0] data_in;
input load;
input out_en;
output [3:0] data_out;

wire [3:0] data_i, data_o;

// instantiate D flip flops here
DFF dff_0 (.clk(clk), .D(data_i[0]), .Q(data_o[0]));
DFF dff_1 (.clk(clk), .D(data_i[1]), .Q(data_o[1]));
DFF dff_2 (.clk(clk), .D(data_i[2]), .Q(data_o[2]));
DFF dff_3 (.clk(clk), .D(data_i[3]), .Q(data_o[3]));

assign data_i = load ? data_in : 4'd0;
assign data_o = out_en ? data_o : 4'd0;

endmodule

// The Top level for the register file is mentioned below
module Register_File(data_out, clk, data_in, read_add, read_en, write_add, write_en);
input clk;
input [3:0] data_in;
input [1:0] read_add, write_add;
input read_en, write_en;
output [3:0] data_out;

wire [3:0] read_sel, write_sel;

// instantiate decoders here

dec2x4 Dec_Read (read_sel, read_en, read_add);
dec2x4 Dec_Write (write_sel, write_en, write_add);

// instantiate registers here
Nibble_reg Reg_0 (data_out, clk, data_in, write_sel[0], read_sel[0]);
Nibble_reg Reg_1 (data_out, clk, data_in, write_sel[1], read_sel[1]);
Nibble_reg Reg_2 (data_out, clk, data_in, write_sel[2], read_sel[2]);
Nibble_reg Reg_3 (data_out, clk, data_in, write_sel[3], read_sel[3]);

endmodule

Add a comment
Know the answer?
Add Answer to:
Objective: Creating a register file (memory) using Verilog. The register file is made up of four registers and each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help doing the code using Verilog modelsim Design a 32-bit register using the D...

    I need help doing the code using Verilog modelsim Design a 32-bit register using the D Flip-Flop from part (1) so that it has the following features: (a) The Register has these ports Outputs: Q[31:0] Inputs: D[31:0] CLK is the clock signal EN is a synchronous signal for enabling the register. When EN is asserted at the sensitive edge of the CLK, the input D is loaded into the register. RESET We will leave this input unconnected, but will define...

  • Suppose we have a Register File that contains 256 registers. Each register stores 64 bits of data. In the register file...

    Suppose we have a Register File that contains 256 registers. Each register stores 64 bits of data. In the register file below, write the number of bits traveling on each of the lines labeled 1, 2, 3, and 4 (the width of the lines) ReadRegisterl Register0 ReadDatal Registerl 3 Register2n-2 ReadRegister2 MI ReadData2 咀 Number of lines on one input to MUX Suppose we have a Register File that contains 256 registers. Each register stores 64 bits of data. In...

  • EEL4768C Lab Assignment 6 (40 points) Due 7/24/2018, 11:59 pm on Canvas Register file is an...

    EEL4768C Lab Assignment 6 (40 points) Due 7/24/2018, 11:59 pm on Canvas Register file is an important state element of the MIPS processor. Consider the register file shown below. The register file can read and write the data into the registers. The register file has two read ports (A1, A2) and one write port (A3). The width of Al, A2 and A3 is 5 bits. Writing data into the register is synchronized with the clock signal. WE is the write...

  • WRITE THE CODE IN VERILOG: Instead of using Registers, USE D FLIP FLOPS and a clock....

    WRITE THE CODE IN VERILOG: Instead of using Registers, USE D FLIP FLOPS and a clock. Include the logic for a reset A sequential circuit with three D flip-flops A, B, and C, a trigger x, and an output z1, and zo. On this state machine diagram, the label of the states are in the order of (ABC), the transition is the one bit x, and the output is under the forward slash. x/z1zo. The start state is 001 0/01...

  • Question 1 Figure 1 shows a datapath for R-type instructions which consits of a register file...

    Question 1 Figure 1 shows a datapath for R-type instructions which consits of a register file and an arithmetic logic unit (ALU). These instructions are also known as aritmetic-logical- instructions since they perform aritmetic or logical operations. The register file contains all the registers and provides two read ports and one write port. The register file always provides the contents of the registers corresponding to the read register inputs on the outputs, while the writes must be explicitly controlled with...

  • Register File Consider the following register file, that provide one write port and two read ports....

    Register File Consider the following register file, that provide one write port and two read ports. A register is updated on the positive edge on the clock if dw=1. Data is written to rd. The two read ports are: rn and rm. typedef logic [15:0] reg16_t; typedef logic [2:0] reg_sel_t; module reg_file( output reg16_t rn, rm, input reg16_t rd, input reg_sel_t n, m, d, input logic dw, reset, clk ); Use behavioural Verilog to implement reg_file. module reg_file( output reg16_t...

  • Use the Quartus Prime Text Editor to implement a structural model of the 4-bit data register show...

    Use the Quartus Prime Text Editor to implement a structural model of the 4-bit data register shown above in a file named reg_4bit.sv. Specify the 4-bit data register’s module according to the interface specification given in the table below. Port Mode Data Type Size Description RST in logic 1-bit Active high asynchronous reset CLK in logic 1-bit Synchronizing clock signal EN in logic 1-bit Synchronous clock enable D in logic vector 4-bits Synchronous data input Q out logic vector 4-bits...

  • Design a 3- bit Multipurpose Register. The register utilizes 3 "D" type flip flops with outputs...

    Design a 3- bit Multipurpose Register. The register utilizes 3 "D" type flip flops with outputs Q0, Q1, Q2. The Registers has a synchronous clock input(CLK) that clocks all 3 flip flops on its positive edge The Registers has an asynchronous clear input(CLR' ) that sets all flip flops to "0" when active low. The Register has 2 select inputs, S0 and S1 that selects the functions as folows: S1 = 0, 0, 1, 1 and S0 = 0,1,0,1 and...

  • a Read the following codes in Verilog and the corresponding testbench file. Describe what the codes...

    a Read the following codes in Verilog and the corresponding testbench file. Describe what the codes are doing by adding comments in the code. Then write down the simulation results of res1, res2, res3, and res4, respectively. Source code module vector_defn (num1, res1, res2, res3, res4); input [7:0] num1; output res1; output [3:0] res2; output [0:7] res3; output [15:0] res4; assign res1=num1[2]; assign res2=num1[7:4]; assign res3=num1; assign res4={2{num1}}; endmodule testbench: `timescale 1ns / 1ps module vector_defn_tb; reg [7:0] in1; wire...

  • Consider the circuit in Figure 1. It is a 4-bit (QQ2Q3) synchronous counter which uses four T-typ...

    Consider the circuit in Figure 1. It is a 4-bit (QQ2Q3) synchronous counter which uses four T-type flip-flops. The counter increases its value on each positive edge of the clock if the Enable signal is asserted. The counter is reset to 0 by setting the Clear signal low. You are to implement an 8-bit counter of this type Enable T Q Clock Clear Figure 1. 4-bit synchronous counter (but you need to implement 8-bit counter in this lab) Specific notes:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT