Thursday, 17 August 2017

FPGA Verilog 4 bit two input multiplexer using a for loop to create instances Structural design using components Xilinx Spartan 3 development board



This video is part of a series to design a Controlled Datapath using a structural approach in Verilog. A Structural approach consist in designing all components needed for the design such as gates to form subsystems and then joining them together to form a larger design like adders and Arithmetic logic units.

The design in these labs was first developed in VHDL you can check the final VHDL version in the link below as well as instructions on how to set up the Waveshare development board to get started, the setup is the same for VHDL and Verilog:

The complete vhdl video tutorial at:

https://youtu.be/_lZcWH0gjIw?list=PLZqHwo1YWqVMSdkQOYC_W0o59LWnZvFn4

Lab Sheets:

http://viahold.com/y37

Lab guide

http://cogismith.com/1OwP

 module nbit_multiplexer  
 #(parameter N=4)  
 (input [N-1:0]bin0,  
 input [N-1:0]bin1,  
 input sel,  
 output [N-1:0]mux_out);  
 genvar i;  
  generate  
          for (i=0;i<N;i=i+1)   
                 begin: generate_mux  
         two_input_multiplexer mux(.bin0(bin0[i]),.bin1(bin1[i]),.sel(~sel),.mux_out(mux_out[i]));        
      end  
  endgenerate  
 endmodule  


COMPONENT 1 BIT 2 INPUT MULTIPLEXER



 module two_input_multiplexer(  
   input wire bin0,  
   input wire bin1,  
       input wire sel,  
   output mux_out  
   );  
          //if select is 0 chose bin0 otherwise bin1    
 assign mux_out = sel ? bin1 : bin0 ;  
 endmodule  

No comments:

Post a Comment