Verilog: Codificadores Y Decodificadores
Verilog: Codificadores Y Decodificadores
CODIFICADORES Y DECODIFICADORES
input habilitacion;
genvar 1
always @ (ent)begin
sal = 0;
case (ent)
endcase;
end
endmodule
parameter ANCHO = 4;
integer i;
always @ (solicitud)
begin
codigo = 0;
gs = 1;
if (solicitud[i]) begin
gs = 0;
codigo[i] = 1;
end
end
endmodule
CODIGO GRAY
always @ (ent)begin
sal = 0;
case (ent)
endcase;
end
endmodule
CODIFICADOR 9x3
parameter ANCHO = 3;
integer i;
always @ (ent) begin
prioridad = 1;
sal= 0;
if (ent[i]) begin
priodidad = 0;
sal[i] = 1;
end
end
endmodule
integer i;
gs = 1;
sal = 0;
if (ent[i]) begin
gs = 0;
sal[i] = 1;
end
end
endmodule
MULTIPLEXORES
module mux4a1 (ent,sal,control,enable)
parameter ANCHO = 4;
input enable;
output sal;
endmodule
TESTBENCH
TESTBENCH PARA DECODIFICADOR 1X2
reg ent;
initial begin: TB
integer i;
$dumpfile("test.vdc");
$dumpvars(0,dec1x2_tb);
ent=i;
#10;
end
endmodule
wire salD,salI;
always begin
#6 MCLK = 1; #4 MCLK = 0;
end
initial begin: TB
integer i;
$dumpfile("test.vdc");
$dumpvars(0,testbasic);
MCLK = 1;
testvector = 10'b0011100111;
ent = testvector[i];
#10;
$finish(1);
end
endmodule
TESTBENCH BIESTABLE JK
module jkff_tb();
wire q;
always begin
#6 MCLK = 1; #4 MCLK = 0;
end
integer i;
testvectorJ = 9b'010101011;
testvectorK = 9b'110010111;
MCLK = 1;
$dumpfile("test.vcd");
$dumpvars(0,jkff_tb);
qold = q;
J = testvectorJ[i];
K = testvectorK[i];
#10;
end
$finish(1);
end
endmodule
CIRCUITOS SECUENCIALES
BIESTABLE JK
module jkff(CLK,J,K,Q);
input CLK, J, K;
output reg Q = 0;
case ({J,K})
1: Q <= 0;
2: Q <= 1;
3: Q <= ~Q;
default Q <= Q;
endcase
endmodule
BIESTABLE RS
module rs_ff(rs,clk,q,qb);
input clk;
begin
case(rs)
2'b00: q = q;
2'b01: q = 1'b1;
2'b10: q = 1'b0;
2'b11: q = 1'bx;
endcase
qb = ~q;
end
endmodule
BIESTABLE T
module t_ff(t,clk,q,qb);
input t;
input clk;
case(t)
1'b0: q = q;
1'b1: q = ~q;
endcase
qb = ~q;
end
endmodule
REGISTRO DE DESPLAZAMIENTO
case (sel)
default: Q<=8'bx;
endcase
endmodule
CONTADOR JOHNSON
input CLOCK_50;
wire CLK1;
reg [7:0] Q;
assign G_LED = Q;
initial Q = 0;
else
endmodule
DISPLAY
initial Q = 48'hB00B5A55;
if (SW[0]) Q<=0;
endmodule
CONTADOR BÁSICO
initial Q = 0;
if (SW[0]) Q<=0;
else Q<=Q+1;
endmodule
DIVISOR DE FRECUENCIA
module ex(in1,in2,clk,sal,divfre);
begin
end
end
always @(posedge divfre) //Cuando frivfre tenga pulso de subida (Para cada ciclo)
begin
endcase
end
endmodule
ENSAMBLADOR
Ejercicio 1:
.data
negat: .word -50 @Valor negativo para inicializar la comparativa de valores negativos
.text
mov r6, #0
mov r2, #0
ldr r7, =N
beq stop
bpl suma
cond2: cmp r4, r3 @Condicional del mayor de los negativos
bgt Neg
b bucle
b bucle
b bucle
stop: wfi
Ejercicio laboratorio:
.data
V: .word 10, 20
n: .word 2
suma: .word 0
.text
ldr r1, =n
mov r3, #0
beq finbuc
b bucle
stop: wfi
Desplazamiento aritmético a la derecha —arithmetic shift right—:
• «asr rd, rm, #Shift», desplaza el contenido de rm hacia la derecha conservando su signo, tantas
veces como las indicadas por el dato inmediato «Shift», y almacena el resultado en rd (es decir,
rd ← rm >>a Shif t).
• «asr rd, rs», desplaza el contenido de rd hacia la derecha conservando su signo, tantas veces
como las indicadas por el byte más bajo de rs (es decir, rd ← rd >>a rs). 3