Question: module TestBench ( ) ; reg clk _ enable, reset, CLK; wire [ 1 5 : 0 ] Rand _ out, preset _ 0 2
module TestBench;
reg clkenable, reset, CLK;
wire : Randout, preset;
Instantiate Main module
Main DUTRandout, CLK clkenable, reset, preset;
Instantiate Lsfr module
Lsfr DUT
clkCLK
resetreset
enableclkenable
lfsroutpreset
;
Clock generation
always begin
#
CLK ;
#
CLK ;
end
Initialize inputs
initial begin
clkenable ;
reset ;
#; Wait for time units for initialization
Print Randout
$displayRandout b Randout;
Finish simulation
$finish;
end
endmodule this the testbench file module Main
output : Randout,
input clkenable, reset, preset CLK
;
wire : Splittercmb;
wire andout, q q q q q q q q q q q q q q q q;
wire xorout, xorout, xorout;
assign andout clkenable & CLK;
DflipFlop #WIDTH flipflopqqqinvclkandoutdarstresetpreenpreset;
DflipFlop #WIDTH flipflopqqqinvclkandoutdqarstresetprepreseten;
Instantiate other D flipflops similarly
assign Splittercmb q q q q q q q q q q q q q q q q;
assign Randout Splittercmb;
assign xorout q q;
assign xorout q xorout;
assign xorout q xorout;
DflipFlop #WIDTH flipflopqqqinvclkandoutdxoroutarstresetprepreseten;
endmodule this the design.sv module Lsfr
input clk
input reset,
input enable,
output reg : lfsrout
;
Internal registers
reg : lfsrreg;
always @posedge clk or posedge reset begin
if reset
lfsrreg hFFFF; Initialize LFSR to all ones when reset is active
else if enable begin
Feedback logic
lfsrreg lfsrreg lfsrregb; Feedback polynomial: x x
Shift right
lfsrreg lfsrreg: lfsrreg; Shift right by bit
end
end
Output
assign lfsrout lfsrreg;
endmodule lsfrv module DflipFlop
output reg q
input clk
input arst
input pre,
input en
input : d
;
always @ posedge clk or posedge arst
if arst
q b;
else if en b
q d;
endmodule dflipflop.v can you fix it in verilog using the edaplayground
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
