Question: Please write a testbench code that simulates pressing two random number buttons once each, as well as pressing the left and right shift buttons once

Please write a testbench code that simulates pressing two random number buttons once each, as well as pressing the left and right shift buttons once each. ```
module LCD_control Ier(rst, clk, Icd_e, Icd_rs, Icd_rw, Icd_data, led, number_btn, control_btn);
input rst, clk:
input [9:0] number_btn;
input [1:0] control_btn;
wire [9:0] number_btn_t:
wire [1:0] control_btn_t:
oneshot_universal #(.W10TH(12)) A1(clk, rst,{number_btn[9:0], control_btn[1:0]},{number_btn_t[9:0], control_btn_t[1:0]});
output Icd_e, Icd_rs, Icd_rw;
output reg [7:0] Icd_data;
output reg [7:0] led;
wire Icd_e:
reg Icd_rs, Icd_rw;
reg [7:0] cnt;
reg [2:0] state;
parameter DELAY =3'b000,
FUNCTION_SET =3'b001,
DISP_ONOFF =3'b010,
ENTRY_MODE =3'b011,
SET_ADORESS =3'b100,
DELAY_T =3'b101,
HRITE =3'b110,
CURSOR =3'b111;
always @(posedge clk or negedge rst)
begin
if(!rst) begin
state = DELAY;
led =8'b0000_0000;
end
else begin
case(state)
DELAY: begin
if(cnt ==70) state = FUNCTION_SET;
led =8'b1000_0000;
end
``````
FUNCTION_SET : begin
if(cnt ==30) state = DISP_ONOFF;
led =8'b0100_0000;
end
DISP_ONOFF : begin
if(cnt ==30) state = ENTRY_MODE;
led =8'b0010_0001;
end
ENTRY_MODE : begin
if(cnt ==30) state = SET_ADDRESS;
led =8'b0001_0000;
end
SET_ADORESS : begin
if(cnt ==100) state = DELAY_T;
led =8'b0000_1000;
end
DELAY_T : begin
state =|number_btn_t ? HRITE : (|control_btn_t ? CURSOR : DELAY_T);
led =8'b0000_0100;
end
WRITE : begin
if(cnt ==30) state = DELAY_T;
led =8'b0000_0010;
end
CURSOR : begin
if(cnt ==30) state = DELAY_T;
led =8'b0000_0001;
end
endcase
end
end
always @(posedge clk or negedge rst)
begin
if(!rst)
cnt =8'b0000_0000;
else
begin
case(state)
DELAY :
if(cnt >=70) cnt =0;
else cnt = cnt +1;
``````
FUNCTION_SET :
if(cnt >=30) cnt =0;
else cnt = cnt +1;
DISP_ONOFF :
if(cnt >=30) cnt =0;
else cnt = cnt +1;
ENTRY_MODE :
if(cnt >=30) cnt =0;
else cnt = cnt +1;
SET_ADORESS :
if(cnt >=100) cnt =0;
else cnt = cnt +1;
DELAY_T :
cnt =0;
mRITE:
if(cnt >=30) cnt =0;
else cnt = cnt +1;
CURSOR :
if(cnt >=30) cnt =0;
else cnt = cnt +1;
endcase
end
end
always @(posedge clk or negedge rst)
begin
if(lrst)
{|cd_rs, Icd_rw, Icd_data}=10'b0_0_0000_0001;
else
begin
case(state)
FUNCTION_SET :
{Icd_rs, Icd_rw, Icd_data}=10'b0_0_0011_1000;
DISP_ONOFF :
{|cd_rs, Icd_rw, Icd_data}=10'b0_0_0000_1111;
ENTRY_MODE :
{Icd_rs, Icd_rw, Icd_data}=10'b0_0_0000_0110;
SET_ADORESS :
{Icd_rs, Icd_rw, Icd_data}=10'b0_0_0000_0010;
DELAY_T :
{Icd_rs, Icd_rw, Icd_data}=10'b0_0_0000_1111;
HRITE: begin
``````
if(cnt = cov) begin
case(nunber_bin)
```
```
10'b0100_0000_00 : \lcd_rs, lod_rw, Icddatal s=10'01_0_0011_0010;
10%b0010_0000_00 : (lcd_rs. lod_rw. Isd_data)=10'b1_0_0011_0011;
10'b0001_0000_00(icdirs, Icd_r%, lcd_data) ce 10'b1_0_0011_0100:
10'b0000_1000_00 ;./(icd_rs. Ecd_ri#, lcd_data)=10'b1_0_0011_0101;
10'b0000_0100_00 : {Itd_rs,{cd_r%, Icd_data}
Please write a testbench code that simulates

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!