Strumenti Utente

Strumenti Sito


informatica:ae:componentidivisoreverilog

Componenti base

Registro

module registro(output[N-1:0] out,
		input [N-1:0] inp, 
		input 	      beta, 
		input 	      clock);
 
   parameter N = 32;
 
   reg [N-1:0]		     stato;
 
   initial
     begin
	stato = 0;
     end
 
   always @(posedge clock)
     begin
	if(beta)
	  stato = inp;
     end
 
   assign
     out = stato;
 
endmodule

Commutatore

module k2(output [N-1:0]z, 
	  input [N-1:0] x, 
	  input [N-1:0] y, 
	  input 	alpha);
 
   parameter N = 32;
 
   assign 
     #2 z = (alpha ? y : x);
 
endmodule

AluINC

module aluinc(output [N-1:0]z,
	      input [N-1:0] x);
 
   parameter N = 32;
 
   assign #5 z     =  x + 1;
 
endmodule

AluMeno

module alumeno(output [N-1:0]z,
	       output segno,
	       input [N-1:0]x,
	       input [N-1:0]y);
 
   parameter N = 32;
 
   assign #5 z     =  x - y;
   assign #5 segno = (y > x ? 1 : 0);
 
endmodule

Indicatore a transizione di livello in ingresso

//
// modulo RDY (transizione di livello in ingresso) 
// 
 
module rdy(output rdyout,
	   input rdyin,
	   input beta,
	   input clock);
 
   reg 		 stato;
   reg 		 inp;
 
   wire 	 in2, out3;
 
   initial
     begin
	stato = 0;
	inp = 0;
     end
 
   always @(negedge clock)
     begin
	stato = rdyin;
     end
 
   ack contmod2(in2, beta,  clock);
   comp comp2(out3,  stato, in2);
 
 
   assign
     rdyout = out3;
 
endmodule

Indicatore a transizione di livello in uscita

module ack(output ackout,
	   input beta,
	   input clock);
 
   reg stato;
 
   initial
     begin
	stato = 0;
     end
 
   always @(negedge clock)
     begin
	if(beta)
	  stato = ~stato;
     end
 
   assign
     ackout = stato;
 
endmodule

Comparatore

primitive comp(output z,
	    input x,
	    input y);
 
   table
      0 0 : 0;
      0 1 : 1;
      1 0 : 1;
      1 1 : 0;
   endtable
 
endprimitive
informatica/ae/componentidivisoreverilog.txt · Ultima modifica: 18/10/2017 alle 11:34 (7 anni fa) da Marco Danelutto