p5-20 連結運算子{}左移 右移1bit暫存器
適用於DE2-70 實驗板
module SR_SL_1bit (SW, LEDR, LEDG);
input [17:0] SW; // toggle switches
output [17:0] LEDR; // red LEDS
output [7:0] LEDG; // green LEDs
//set original program input , output
wire [7:0]din;
wire l_r;
wire [7:0]sht_out;
//mapping to hardware
assign LEDR = SW;
assign din =SW[7:0];
assign l_r=SW[17];
//original program
reg [7:0]cnt;
always @(l_r or din)
begin
cnt=din;
if (l_r)
cnt ={cnt[6:0],1'b0};
else
cnt ={1'b0,cnt[7:1]};
end
assign sht_out=cnt;
//assign output LED
assign LEDG[7:0]=sht_out;
endmodule
/*
module sht_r_l(din,l_r,sht_out);
input [7:0]din;
input l_r;
output [7:0]sht_out;
reg[7:0] cnt;
always @(l_r or din)
begin
cnt = din ;
if (l_r)
cnt = {cnt[6:0],1’b0};
else
cnt = {1’b0 ,cnt[7:1]};
end
assign sht_out=cnt;
endmodule
*/
沒有留言:
張貼留言