Académique Documents
Professionnel Documents
Culture Documents
Configuración
del entorno
VERILOG Primer
programa
Elementos
básicos
Estructura
Registros
INTRODUCCIÓN
¡ Queremos un programa que nos salude con la frase “Hola, mundo”
¡ Abrid un fichero de texto que se llame hello.v y copiad lo siguiente
module hello;
initial
// Imprimimos el mensaje y un salto de lInea
$display("Hola, mundo\n");
endmodule
COMPILACIÓN Y EJECUCIÓN
#! /usr/bin/vvp!
:ivl_version "0.9.2 " "(v0_9_2)";!
:vpi_time_precision + 0;!
Queremos ver en pantalla :vpi_module "system";!
:vpi_module "v2005_math";!
“Hola, mundo” :vpi_module "va_math";!
S_0x9010aa0 .scope module, "hello"
"hello" 2 2;!
.timescale 0 0;!
.scope S_0x9010aa0;!
T_0 ;!
programación %vpi_call 2 5 "$display",
"Hola, mundo\012";!
%end;!
.thread T_0;!
compilación # The file index is used to find
the file name in the following
iverilog hello.v –o hello!
hello.v hello table.!
:file_names 3;!
"N/A";!
"<interactive>";!
/* Programa de ejemplo: hello.v */ "hello.v";!
module hello;
initial
// Imprimimos el mensaje y un salto de lInea ejecución
$display("Hola, mundo\n");
./hello!
endmodule
“Hola, mundo”
¡ C ompila y ejecuta el
programa “Hola, mundo”
EJERCICIO
COMENTARIOS
cadena de texto
variables $display texto por pantalla
Formato Descripción
%d! Entero en decimal
%b! Entero en binario
%o! Entero en octal
%h! Entero en hexadecimal
%c! Carácter
%s! Cadena de caracteres
%f! Real en formato decimal
%e! Real en formato científico
%g! Real en el formato más corto de los dos anteriores
BLOQUES DE CÓDIGO
integer i;!
real f;!
!
initial!
begin!
i=4;!
f=2.7172;!
$display("i vale %d y f vale bloque initial
%g",i,f);!
end!
ESTRUCTURA DEL PROGRAMA
bloque “initial”
área de instrucciones
a través de Verilog:
§ Expresa en decimal el número
hexadecimal 0x1FEA
§ Ídem para el número 1000101 2
§ Ídem para el octal 1234
§ Pasa a hexadecimal el binario
1010011 2
REGISTROS