Question

The schematic of a positive edge-triggered 4-bit, parallel-in, parallel-out data register active high asynchronous reset is b

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

Current/present state (data) stored by the register.

Qbar

out

logic vector

4-bits

Inverted current/present state (data) stored by the register.

Within the declaration portion of the module, perform the following declarations:

Declare a constant named REG_WIDTH (using ALL CAPS) of type integer and assign it to 4. See the example shown below.

                         localparam REG_WIDTH = 4;

Within the implementation portion of the module, model the parallel-in, parallel-out data register according to the following modeling specifications:

• Use a concurrent for-generate statement with the following attributes:o AgeneratelabelnamedFF_stages

  • A generate parameter named k

  • A range that includes constant REG_WIDTH and a down to direction.

o A generate body that uses a concurrent module instantiationstatement to instantiate the D flip-flops. Use an instance label named FFand associate the ports of the instances using named association.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// RTL code in System verilog

//D Flip Flop in SV

module d_flop(

input logic RST,CLK,EN,D, //Input port Declaration

output logic Q,Qbar //Output port Declaration

);

logic Qtemp; //Internal Variable

//Sequential BLOCK using nested if

always_ff @(posedge CLK or posedge RST) begin

if(RST) //Set = 1 or posedge of RST

Qtemp <= 1'b0;

else if(EN) //EN = 1

Qtemp <= D;

else //EN = 0, HOLD previous value

Qtemp <= Qtemp;

end

  

//Assigning Output Ports

assign Q = Qtemp;

assign Qbar = ~Qtemp;

endmodule

//Data Register code in SV

module data_register(RST,CLK,EN,D,Q,Qbar);

localparam REG_WIDTH = 4;

input logic RST,CLK,EN; //Input port Declaration

input logic [REG_WIDTH-1:0]D; //Data Input port Declaration

output logic [REG_WIDTH-1:0]Q,Qbar; //Output port Declaration

// D flip flop Instantiation using generate loop based on local parameter

generate

genvar k;

for(k=0 ; k<REG_WIDTH ; k++)

begin : DFF_Instance

d_flop DFF(RST,CLK,EN,D[k],Q[k],Qbar[k]);

end

endgenerate

endmodule

//Testbench in SV

module test;

logic RST,CLK,EN;

logic [3:0]D,Q,Qbar;

//Instantiation of Data Register

data_register DATA_REGISTER(RST,CLK,EN,D,Q,Qbar);

//Driving Clock

always begin

#5 CLK = 1'b0;

#5 CLK = ~CLK;

end

  

//Driving Stimulus

initial begin

RST = 1'b1;

@(posedge CLK) RST = 1'b0;

EN = 0; D = 0;

@(posedge CLK) EN = 0; D = 9;

@(posedge CLK) EN = 1; D = 10;

@(posedge CLK) EN = 1; D = 0;

@(posedge CLK) EN = 1; D = 15;

@(posedge CLK) EN = 0; D = 0;

@(posedge CLK) EN = 1; D = 9;

@(posedge CLK) EN = 0;

@(posedge CLK) $finish;

end

endmodule

//Simulation Waveform

M Modelsim PE Student Edition 104 File Edit View Compile Simulete Add Wave Tools Layout BookmarksWindow Help 凸庬 elave-Default

// QUARTUS synthesis

n Report data register Flow Summary Entityinstance of Contents Cyclone Ⅳ E: AUTO data_ register Flow Summary Flow Settings Fl

// RTL SCHEMATIC OBTAINED FROM QUARTUS SYNTHESIS

d ropsiorr instanceloj.DrFi CLK CLU 0 Qbar Obar3.0] D 에 EN RST d flop.DFF instancel1].DFF CLK Obar EN d flop:DFF Instance 2].

Add a comment
Know the answer?
Add Answer to:
Use the Quartus Prime Text Editor to implement a structural model of the 4-bit data register show...
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
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