2014年5月21日 星期三

4bit 4channel 多工暫存器 ---適用於DE2-70




 module Mux_4ch_4bit(CLOCK_50,KEY,SW,LEDR);

 input CLOCK_50; //50MHz時鐘
 input [0:0]KEY; //重置 reset

 input  [17:0]SW ;
 output [17:0] LEDR;


 //EX_paral_muxed_reg (clk, reset, a, b, c, d, sel, q);


EX_paral_muxed_reg(CLOCK_50,KEY[0],SW[15:12],SW[11:8],SW[7:4],SW[3:0],SW[17:16],LEDR[3:0]);


endmodule






module EX_paral_muxed_reg (clk, reset, a, b, c, d, sel, q);

input   clk, reset;
// input [7:0] a, b, c, d;          配合DE2-70 改成4bits 4channel
 input [3:0] a, b, c, d;    //data input  4 channel    4bits/ch
input [1:0] sel;    //select line
// output reg  [7:0] q; 配合DE2-70 改成4bits 
output reg  [3:0] q;     //output register 

always @ (posedge clk or negedge reset)

begin
if (!reset)
 // q <= 8'h00; 配合DE2-70 改成4bits 
             q <= 4'h00;

else

 case (sel)
   2'b00 :   q <=  a;
   2'b01 :   q <=  b;
   2'b10 :   q <=  c;
   2'b11 :   q <=  d;
   default : q <=  a;
 endcase
end

endmodule


沒有留言:

張貼留言

Node-Red & ModeBus FC=1

Node-Red & ModeBus FC=1 write address=0..7   8bits read address=16..23 8bits  [{"id":"cf7c1253d4d997dd","type&q...