Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisione Revisione precedente
Prossima revisione
Revisione precedente
vlsi:workbook:digital:hdlsim:vhdl_tutorials [23/11/2013 17:57]
panati
vlsi:workbook:digital:hdlsim:vhdl_tutorials [24/11/2013 20:38] (versione attuale)
panati
Linea 1: Linea 1:
-===== VHDL simulation ​examples ​=====+===== VHDL simulation ​tutorials=====
  
-==== A simple Shift Register (VHDL example) [IT] ==== 
  
-                                                    (work in progress...)+----
  
-=== Organizzazione del progetto ​===+==== A simple Shift Register ====
  
-Come primo, lapalissiano,​ step c'è la decisione del progetto che vogliamo sviluppare in linguaggio VHDL; per iniziare svilupperemo in questo tutorial un semplice shift register che permetta di fare i primi passi nella progettazione su ASIC.+                                               
 +=== Project outline ===
  
-Innanzitutto è necessario provvedere alla creazione di uno spazio in cui lavorareorganizzandolo al fine di evitare confusione tra i files che ci serviranno durante tutto il digitalflow+First of allwe have to decide what kind of project we're going to do in VHDL language.
  
-L'ordine è fondamentale per cui è molto importante fin da subito cercare di evitare mix di files per procedure differenti: questo ci eviterà ​in futuro di sprecare tempo prezioso (e.g. impiegabile nel debugging o nell'ottimizzazione del dispositivo) nella ricerca spasmodica di files.+In the following tutorial we'll develop a very simple shift register ​in order to understand the first steps of ASIC programmingIt is necessary to create a well organized working space in order to avoid confusion among files and directories that we'll use during the digital flow.
  
-Un esempio potrebbe essere quello rappresentato ​in figura:+To be ordered is extremely important ​in life! :-) and also here could let you avoid wasting a lot of time... 
 + 
 +In the following picture you can see an example of directories'​ tree for our project:
  
 {{ :​vlsi:​workbook:​digital:​albero1.png?​600 }} {{ :​vlsi:​workbook:​digital:​albero1.png?​600 }}
    
-All’interno della cartella ​''​projects'' ​è stata creata una cartella ​''​shiftregister'' ​che conterrà tutti files inerenti al nostro progetto ​(librerie della tecnologia usata escluse).+In the ''​projects'' ​directory another directory ​''​shiftregister'' ​has been created, and this one will contain all the files pertinent with the project ​(with the exception of the technology libraries)
  
-Anche se non verranno usate nell’immediatoè conveniente iniziare a preparare anche le cartelle che saranno utili negli step successivi: nella cartella ​''​shiftregister'' ​infatti vediamo:+Even if we won't use immediately all the directorieswe can create them right now; in the ''​shiftregister'' ​directory we can see:
  
   * ''​lec''​ (//logic equivalence check//)\\   * ''​lec''​ (//logic equivalence check//)\\
Linea 25: Linea 27:
   * ''​syn_shiftregister''​ (ci serve per la //​sintesi//,​ ed è la cartella che prenderemo in considerazione ora).\\   * ''​syn_shiftregister''​ (ci serve per la //​sintesi//,​ ed è la cartella che prenderemo in considerazione ora).\\
  
-All’interno di ''​syn_shiftregister'' ​prepariamo altre cartelle dall’uso non immediato:+Into ''​syn_shiftregister'' ​directory we can prepare others directories
  
   * ''​db''​\\   * ''​db''​\\
Linea 35: Linea 37:
   * ''​work''​\\   * ''​work''​\\
  
-Ci metteremo ora nella cartella ​''​netlist_in'' ​e qui prepareremo due files vuoti con estensione ​''​.vhd'':​+Now, in the ''​netlist_in'' ​directory, we can create two empty files with a ''​.vhd'' ​extension
  
-• il primo lo chiameremo ​**shiftregister.vhd** (sarà il file sorgente),\\ +• the first, we will name **shiftregister.vhd** (this is the source ​file),\\ 
-• il secondo ​**tb_shiftregister.vhd** (sarà il file di test bench).(( Nota: per facilitarci in seguito con simulazione e sintesi e nella distinzione a colpo d’occhio della tipologia dei files all’interno delle cartelle, è conveniente nominare il file di test bench come l’entity a cui si riferiscono precedendoli dal prefisso ''​tb''​ eventualmente numerato nel caso si vogliano utilizzare diversi test benches, come ad esempio **tb01_shiftregister.vhd**,​ **tb02_shiftregister.vhd**,​ **tb350_shiftregister.vhd** etc. Qui svilupperemo solo un test bench, per cui il nome non appare dotato di numerazione.)) \\+• the second, ​**tb_shiftregister.vhd** (this is the test bench file).
  
-=== Schematizzazione del progetto e implementazione ​in VHDL ===+Note that, in order to have a simpler life in the later steps (simulation and synthesis) and in order to recognize immediately which file is a ''​source file''​ and which is a ''​test bench''​ file, we could name the source file with the same name of the entity, (i.e. ''​shiftregister.vhd''​) and the test bench file with the same name of the source file with the exception of a ''​tb_''​ suffix (i.e. ''​tb_shiftregister.vhd''​). ​
  
-È fondamentale che sia ben chiaro l’obiettivo che si deve raggiungere.+In the case we have some test benches, we can also enumerate them, in this way: **tb01_shiftregister.vhd**,​ **tb02_shiftregister.vhd**,​ **tb350_shiftregister.vhd** etc. Here we'll use only one test bench, so we won't enumerate the file
  
-È buona norma quindi schematizzare ciò che vogliamo ottenere dal nostro progetto e le modalità di costruzione dello stesso da un punto di vista logico.+=== VHDL implementation ===
  
-Ad esempiopossiamo pensare di voler realizzare uno shift register; decidiamo che nè gli ingressi nè e le uscite debbano essere dei bus, per cui sono tutti definiti come ingressi/​uscite ​standard logic.+In our examplewe decided to implement a shift register ​in which we have serial input and output (they'​re ​standard logic); so we have just defined an object like this: 
  
 {{ :​vlsi:​workbook:​digital:​sr_scheme.png?​400 }} {{ :​vlsi:​workbook:​digital:​sr_scheme.png?​400 }}
  
-Decidiamo ​in questo frangente se vogliamo usare una logica positiva oppure negativa: nel nostro caso il caso logico ​TRUE è 1, il caso logico ​FALSE è (logica positiva). Per cui sarà a 1 l’uscita TRUE mentre le altre saranno a 0 (FALSE).+Now we can decide if we want a positive or a negative logic; ​in the first case we consider the TRUE case equal to and the FALSE case equal to 0; in the second one, it is just the opposite. 
 + 
 +We can write, then, the VHDL model including the process that allow us to select the right output:
  
-Scriviamo quindi il modello VHDL comprensivo del processo che ci permette di selezionare l’output corretto: 
  
 <code vhdl> <code vhdl>
Linea 100: Linea 103:
 </​code>​ </​code>​
  
-e lo salviamo.+and then we save it.
  
 === Test bench === === Test bench ===
-A questo punto è necessario preparare un file di test bench per lo shift register. + 
-Per farlo utilizziamo l’altro ​file vuoto precedentemente creato.+Now it is necessary to write a test bench file, like this:
  
 <code vhdl> <code vhdl>
Linea 194: Linea 197:
 </​code>​ </​code>​
  
-All’interno del test bench viene istanziato il componente che vogliamo simulare ​(in questo casol’unico componentema il VHDL permette l’istanziazione di molto componenti nel medesimo test bench), vengono dichiarati i segnali internila mappatura porta-segnaleil processo di iniezione di valori negli ingressi; nell’esempio è stata attivata l’azione di shift e ad intervalli di un periodo di clock sono stati inseriti alcuni valori di ingresso al registro (0 → 1 → 0 → 1) (vedi figura seguente)).+In the test bench code we can see the instantiation of the component that we want to simulate ​(in this examplewe have only one componentbut VHDL allows instantiation of more than one component); in additionthere are the definitions of internal signalsport-signal mapping and various processes in order to force inputs to 0 or 1 values. 
 + 
 +In this examplewe can see that the shift-process is active and input values are forced after a clock period.
  
 {{ :​vlsi:​workbook:​digital:​reg.png?​300 }} {{ :​vlsi:​workbook:​digital:​reg.png?​300 }}
  
-La riga+Line
  
 <code vhdl> <code vhdl>
Linea 204: Linea 209:
 </​code>​ </​code>​
  
-rappresenta un trucco per far sì che la simulazione si blocchi al termine dell’ultimo valore forzato negli ingressisenza dover stoppare la simulazione dall’interfaccia grafica del simulatore di Cadence.+represents a trick in order to stop the simulation when the last values is forcedwithout stopping it using the GUI of Cadence ​SimVision. 
 + 
 +The last part of this code represents the configuration file that connects each component to its entity.
  
-L’ultima parte riguarda il file di configurazione che collega ogni componente alla sua entity. 
  
 <code vhdl> <code vhdl>
Linea 221: Linea 227:
 </​code>​ </​code>​
  
-=== Simulazione ​===+=== Simulation ​===
  
-Per la simulazione useremo i tools di Cadence NCLaunch e SimVision.+For the simulation we can use Cadence NCLaunch e SimVision ​tools.
  
-Dalla home ci spostiamo nella cartella ​''​netlist_in''​+Let's move from ''​home''​ directory to ''​netlist_in''​:
  
 <​code>​ <​code>​
Linea 231: Linea 237:
 </​code>​ </​code>​
  
-e digitiamo+and let's write
  
 <​code>​ <​code>​
Linea 237: Linea 243:
 </​code>​ </​code>​
  
-e facciamo Invioalla richiesta di quale tool usare scriviamo+and let's press Enterthen we can choose the tool with:
  
 <​code>​ <​code>​
Linea 243: Linea 249:
 </​code>​ </​code>​
  
-e di nuovo Invioselezioniamo poi la tecnologia che vogliamo usarenell’esempio, Tower Jazz, perciò+and press Enter another timethen let's select the technology we want to usein this examplewe'll choose  ​Tower Jazz, so:
  
 <​code>​ <​code>​
Linea 249: Linea 255:
 </​code>​ </​code>​
  
-e InvioNel nuovo terminale apertosidigitiamo+and then EnterA new terminal will openand in this window writing
  
 <​code>​ <​code>​
Linea 255: Linea 261:
 </​code>​ </​code>​
  
-e Invioe si aprirà la finestra a sfondo grigio mostrata ​in figura.+and pressing Enterthe window showed ​in the following picture will appear.
  
 {{ :​vlsi:​workbook:​digital:​nclaunch01.png?​600 }} {{ :​vlsi:​workbook:​digital:​nclaunch01.png?​600 }}
  
-Oracliccando due volte direttamente su **shiftregister.vhd** (colonna a sinistra) (oppure cliccandoci sopra selezionandolo e successivamente cliccando sul tasto VHDL, cioè l’icona nella barra degli strumenti con un simbolo di ingranaggio meccanicosi compila il file.+Nowit is possible to compile the file by clicking two times on **shiftregister.vhd** (left columnor by selecting the name and then clicking on the VHDL button ​(with a gear symbol).
  
-In basso, nella console, ​comparirà lo script ​del comando appena lanciatosegnali di errore ​(qualora ce ne fossero), uso di memoria e CPU; nel nostro caso, ad esempio:+Below into the console, ​it is possible to see the script ​of the commanderror signals ​(if there were), memory and CPU usein our case:
  
 <​code>​ <​code>​
Linea 276: Linea 282:
 </​code>​ </​code>​
  
-Vale lo stesso procedimento per il file di test bench; doppio click sul file (o selezione del file e successivo click sul tasto VHDL) medesimo controllo nella console.+The procedure for the test bench is totally the same. 
 + 
 +In the case of error, i.e. forgetting in line 49 the last semicolon:
  
-Nel caso di errori, ad esempio dimenticando nella riga 49 del test bench il punto e virgola finale: 
  
 <​code>​ <​code>​
Linea 284: Linea 291:
 </​code>​ </​code>​
  
-anziché+instead of
  
 <​code>​ <​code>​
Linea 290: Linea 297:
 </​code>​ </​code>​
  
-la console ​restituisce una serie di linee di errore recanti la tipologia ​(//expeting ​semicolon//​) ​e la riga (49).+we can read some warnings in the console, specifying the error type (//expecting ​semicolon//​) ​and the line in which there it is (49). 
 + 
 +{{ :​vlsi:​workbook:​digital:​consoleconsenzaerrori.png?​590 }}
  
-{{ :​vlsi:​workbook:​digital:​consoleconsenzaerrori.png?600 }}+In this way it is possibile debugging codes until they are without errors or problems.
  
-In questo modo è possibile debuggare i due codici fino a quando non sono completamente privi di errori.+Then we can elaborate our projectIn the right column, under the ''​worklib''​ directory, there are three IC symbols, with some titles:
  
-A questo punto si passa all’elaborazione;​ nella colonna più a destra, sotto la cartella ''​worklib'',​ compaiono tre simboli di circuito integrato, recanti la scritta: 
  
   * **shiftregister** \\   * **shiftregister** \\
Linea 302: Linea 310:
   * **tbc_shiftregister** \\   * **tbc_shiftregister** \\
  
-selezioniamo col mouse **tbc_shiftregister** (file di configurazionee clicchiamo sul simbolo di elaborazione ​(bottone con un simbolo di graffetta: ​''​Launch Elaborator''​).+we have to select the **tbc_shiftregister** (configuration ​file) and then clicking on the Elaboration button  ​(with a clip image, ​''​Launch Elaborator''​).
  
 {{ :​vlsi:​workbook:​digital:​elaborate.png?​600 }} {{ :​vlsi:​workbook:​digital:​elaborate.png?​600 }}
  
-Se non ci sono problemi, in console ​compariranno solo messaggi riguardanti l’uso di CPU e memoria come questo:+If there aren't problems, in console ​we will see only control messages (CPU and memory use) like this:
  
 <​code>​ <​code>​
Linea 318: Linea 326:
 </​code>​ </​code>​
  
-Contemporaneamentenella cartella ​Snapshot (seconda colonna sotto ''​worklib''​) ​comparirà un file (''​worklib:​ tbc_shiftregister_archi:​configuration''​)lo si seleziona e si clicca sul bottone con la freccia verde in alto (''​Launch Simulator'', ​a destra del ''​Launch Elaborator''​).+At the same timein the Snapshot ​directory ​(second column under ''​worklib''​) ​  ​''​worklib:​ tbc_shiftregister_archi:​configuration'' ​file will appearwe have to select it and then click on the Simulator button  ​(''​Launch Simulator'', ​to the right of ''​Launch Elaborator''​).
  
 {{ :​vlsi:​workbook:​digital:​launchsimulator.png?​600 }} {{ :​vlsi:​workbook:​digital:​launchsimulator.png?​600 }}
  
-A questo punto si apriranno altre due finestre di SimVision: ​il //​DesignBrowser// ​e la //​Console//:​+In this moment two SimVision ​windows will open: //​DesignBrowser// ​and //​Console//:​
  
 {{ :​vlsi:​workbook:​digital:​simvision01.png?​600 }} {{ :​vlsi:​workbook:​digital:​simvision01.png?​600 }}
  
-Consideriamo il //​DesignBrowser//: ​nella colonna a sinistra ampliando il menu ''​(WORKLIB:​TB$\_$SHIFTREGISTER(TB_SHIFTREGISTER_ARCHI))''​ +Let's consider the //​DesignBrowser// ​windowexpanding the menu in the left column ​''​(WORKLIB:​TB$\_$SHIFTREGISTER(TB_SHIFTREGISTER_ARCHI))''​ 
-vediamo che i due processi del test bench (''​generate_clk''​ e ''​values_gen''​) ​e l’istanza ​''​instance_shiftregister'' ​(unica, in questo esempio), e cioè lo shiftregister.+we can see the two processes of the test bench (''​generate_clk''​ e ''​values_gen''​) ​and the instance ​''​instance_shiftregister''​.
  
-  * Cliccando su ''​(WORKLIB:​TB_SHIFTREGISTER(TB_SHIFTREGISTER_ARCHI))'' ​nella colonna di destra compariranno i segnali.+  * By clicking on ''​(WORKLIB:​TB_SHIFTREGISTER(TB_SHIFTREGISTER_ARCHI))'' ​in the right column signals will appear
  
-{{ :​vlsi:​workbook:​digital:​designbrow01a.png?​400 }}+{{ :​vlsi:​workbook:​digital:​designbrow01a.png?​600 }}
  
-  * Cliccando sull’istanza ​(''​instance_shiftregister''​) ​compariranno gli ingressi e le uscite (con un’eloquente simbolo illustrativo). In questo caso ad ingressi ed uscite abbiamo associato lo stesso nome.+  * By clicking on the instance ​(''​instance_shiftregister''​) ​input and output will appear.
  
 {{ :​vlsi:​workbook:​digital:​designbrow01b.png?​600 }} {{ :​vlsi:​workbook:​digital:​designbrow01b.png?​600 }}
  
-A questo punto è possibile selezionare i segnali o i pin da simulare: ​in questo esempio si è deciso di simulare entrambi i gruppi.+Now it is possible to select signals or pin in order to simulate them; in this example both groups are simulated.
  
-A partire da ''​(WORKLIB:​TB_SHIFTREGISTER(TB_SHIFTREGISTER_ARCHI))'' ​si selezionano col mouse i segnali dalla colonna di destra (diventeranno evidenziati ​in gialloe clicco sul tasto con il simbolo di onde quadre rosse e verdi in alto destra. Si aprirà una finestra intitolata ​//Waveform 1//. +Starting by ''​(WORKLIB:​TB_SHIFTREGISTER(TB_SHIFTREGISTER_ARCHI))'' ​we can select the signals ​in the right column (doing this they'​ll appear highlightedand then we can click on the button with a red/green square ​ waveform; then new window named //Waveform 1// will open.
  
-Se vogliamo aggiungere alla simulazione anche le porte dell’istanza,​ torno su //​DesignBrowser//,​ come in precedenza seleziono le porte dell’istanza e clicco sul bottone. 
- 
-La finestra Waveform 1 diventa quindi: 
 {{ :​vlsi:​workbook:​digital:​waveform01.png?​600 }} {{ :​vlsi:​workbook:​digital:​waveform01.png?​600 }}
  
-Col mouse selezioniamo tutta la colonna di sinistra ​(diventerà evidenziata di gialloe premo F2 dalla tastiera oppure dal Menu Simulations → Run. Verrà disegnata la waveform della simulazione.+Now we have to select some (or allthe line in the left column and by clicking ​Menu Simulations → Run (or simply F2) the waveforms will be drawn.
  
 {{ :​vlsi:​workbook:​digital:​waveform02.png?​600 }} {{ :​vlsi:​workbook:​digital:​waveform02.png?​600 }}
Linea 353: Linea 358:
 === Files hdl.var e cds.lib === === Files hdl.var e cds.lib ===
  
-FIXME+The first time the simulation is done, two files are created automatically in the ''​netlist_in''​ folder: 
 + 
 +  * **cds.lib** 
 +  * **hdl.var** 
 + 
 +containing some information about the libraries for the simulation. 
 + 
 +If we are using a choosen technology, in order not to have problems with the post-synthesis simulation, we can add in these files the paths of our technology libraries. 
 + 
 +In this example, we are using Tower Jazz 180 nm technology (if you are using another technology, please ask your supervisor what path you need). 
 + 
 +So, after the first simulation we have, i.e., in ''​cds.lib'':​  
 + 
 +<​code>​ 
 +define worklib /​export/​elt78xl/​disk0/​users/​panati/​projects/​shiftregister/​ 
 +syn_shiftregister/​netlist_in/​INCA_libs/​worklib 
 +include $CDS_INST_DIR/​tools/​inca/​files/​cds.lib 
 +</​code>​ 
 + 
 +and in ''​hdl.var'':​ 
 + 
 +<​code>​ 
 +define WORK worklib 
 +include $CDS_INST_DIR/​tools/​inca/​files/​hdl.var 
 +</​code>​ 
 + 
 +Then, we can change __only the ''​cds.lib''​__ in this way: 
 + 
 +<​code>​ 
 +define worklib /​export/​elt78xl/​disk0/​users/​panati/​projects/​shiftregister 
 +/​syn_shiftregister/​netlist_in/​INCA_libs/​worklib 
 +include $CDS_INST_DIR/​tools/​inca/​files/​cds.lib 
 +DEFINE tsl18fs120_lib /​usr/​tj_lib/​TS18IS_SC/​tsl18fs120/​verilog/​tsl18fs120_lib 
 +</​code>​ 
  
 === SimVision Tip&​Tricks === === SimVision Tip&​Tricks ===
-== Stampa della waverform == 
-In caso fosse necessario esportare la waveform su formato portatile (.pdf) o postscritp (.ps), è possibile salvare tutte le forme d’onda o solo alcune in b/n o rgb andando sul menu della finestra Waveform: File → Print Window. ​ 
  
-La finestra che compare permette di scegliere il percorso del documento che verrà stampatol’intestazioneil tipo di formato ​(A4, A5...), ​l’orientamento della pagina, le onde da stampareil colore di stampa.+== Print the waveforms == 
 + 
 +It is possible to export the waveforms in .pdf or .ps format (color or black and white)just open File → Print Window.  
 + 
 +Here you can choose the document paththe title, the page size (A4, A5...), ​orientationcolors etc.
  
 {{ :​vlsi:​workbook:​digital:​print.png?​600 }} {{ :​vlsi:​workbook:​digital:​print.png?​600 }}
  
-== Arrangiamento visuale ​==+== Visual arrangement ​==
  
-Usando i tasti in alto a destra ​(+, -, =, lente di ingrandimento...) è possibile allargare o rimpicciolire la visuale.  +By using top-right buttons ​(+, -, =, magnifying glass...) it is possible to enlarge or shrink the waveform view.
-Il segno di uguale permette la visualizzazione completa di tutta l’onda.+
  
-== Modifica di valori iniettati negli ingressi del test bench ==+The ''​=''​ symbol allows a synoptic vision.
  
-Senza dover rifare tutta la procedura (test bench, compilazione,​ elaborazione,​ apertura del simulatore, simulazione...) è possibile cambiare i valori iniettati negli ingressi del test bench facendo ripartire la simulazione dal menu Simulation → Reinvoke simulator. In questo modo si può far ripartire il run (F2) con i nuovi valori. Nel caso il simulatore restituisse in questo frangente un errore, è necessario rifare la completa procedura. 
  
-== Colori/​Valori della waveform ​==+== Changing test bench forced values ​==
  
-Dalla colonna ''​Cursor''​ (seconda a partire da destra) cliccando col destro è possibile cambiare il colore della waveform per una migliore lettura e anche del valore del segnale (in decimaleesadecimale...). +You can change forced values ​in the test bench without closing Simvision. After the changeyou can click on Simulation → Reinvoke simulator: in this way you can restart the Run (→ F2with the newer values.
  
-Ad esempio, il default è per gli standard logic il binario e per i bus l’esadecimale.+== Changing values/​color of waveforms==
  
-== Tracer ==+From column ''​Cursor''​ (the second beginning to the right) by right clicking it is possible to change the waveform color and the signal coding (binary, exaadecimal...). ​
  
-Selezionando tutti i segnali e cliccando sul tasto dello ''​Schematic Tracer''​ (barra degli strumenti, settimo bottone a partire da destra verso sinistra, con blocchetti neri tra loro collegatiè possibile ​visualizzare un comodo ​tracer ​che mostra la struttura delle istanze e dei segnali e i valori nel punto in cui è posta il flag del TimeA (che, assieme al flag Baseline permettono di selezionare solo una banda di valori).Per tornare alla schermata con le forme d’onda, è sufficiente ri-cliccare sul simbolo con le onde rosse e verdi.+Default for the standard logic: binary. 
 + 
 +Default for the standard logic vectors: exadecimal.  
 + 
 +== Schematic Tracer == 
 + 
 +By selecting some or all signals and by clicking on the button ​''​Schematic Tracer''​ (the button with some little black wired boxesit is possibile ​to have a useful ​tracer.
  
 {{ :​vlsi:​workbook:​digital:​tracer.png?​600 }} {{ :​vlsi:​workbook:​digital:​tracer.png?​600 }}
  
 + ​--- ​
 +Last Update: [[panati@to.infn.it|Serena Panati]] Nov 24st 2013 //
 +
 +~~NOTOC~~