Industriële fabricage
Industrieel internet der dingen | Industriële materialen | Onderhoud en reparatie van apparatuur | Industriële programmering |
home  MfgRobots >> Industriële fabricage >  >> Industrial programming >> Verilog

Verilog Timescales begrijpen en printen in elke Scope

Standaard timescale

Hoewel Verilog-modules een timescale voor de module verwachten, kunnen simulators een standaard timescale invoegen. De daadwerkelijke timescale die op elk scope in een Verilog-geëlaboreerde hiërarchie toegepast wordt, kan geprint worden met de systeeltaak $printtimescale die de scope als argument accepteert.

module tb;
  initial begin
    // Print timescale van deze module
    $printtimescale(tb);
    // $printtimescale($root);
  end
endmodule

Zie dat zelfs al geen timescale-directive voor deze module geplaatst was, de simulator een 1ns/1ns timescale-waarde toepaste.

Simulatie-log

xcelium> run
Time scale of (tb) is 1ns / 1ns
xmsim: *W,RNQUIE: Simulation is complete.

Standaard timescale scope

Standaard wordt een timescale-directive in een bestand toegepast op alle modules die de directive volgen tot de definitie van een andere timescale-directive.

\`timescale 1ns/1ps
module tb;
  des m_des();
  alu m_alu();
  initial begin
    $printtimescale(tb);
    $printtimescale(tb.m_alu);
    $printtimescale(tb.m_des);
  end
endmodule

module alu;
endmodule

\`timescale 1ns/10ps
module des;
endmodule

In het bovenstaande voorbeeld eindigen tb en alu met een timescale van 1ns/1ns terwijl des een timescale van 1ns/10ps krijgt vanwege de plaatsing van de directive voor de module-definitie van des.

Simulatie-log

xcelium> run
Time scale of (tb) is 1ns / 1ps
Time scale of (tb.m_alu) is 1ns / 1ps
Time scale of (tb.m_des) is 1ns / 10ps
xmsim: *W,RNQUIE: Simulation is complete.

Scope tussen Verilog-bestanden

Andere bestanden kunnen in het huidige bestand opgenomen worden met een \`include directive wat een pre-processor-directive is en de compiler de inhoud van het opgenomen bestand voor compilatie plaatst. Dit is equivalent aan het simpelweg plakken van de volledige inhoud van het andere bestand in dit hoofdbestand.

// main.v
\`timescale 1ns/1ps
module tb;
  des m_des();
  alu m_alu();
  initial begin
    $printtimescale(tb);
    $printtimescale(tb.m_alu);
    $printtimescale(tb.m_des);
  end
endmodule
\`include "file_alu.v"
\`include "file_des.v"

// file_alu.v
module alu;
endmodule

// file_des.v
\`timescale 1ns/10ps
module des;
endmodule

Zie dat resultaten exact hetzelfde zijn als in vorig voorbeeld. alu krijgt een timescale van 1ns/1ps omdat het de laatste directive was die geldig bleef tot de compiler de alu-definitie vond, ondanks het in een ander bestand plaatsen. des krijgt een timescale van 1ns/10ps omdat de directive vervangen werd voor de definitie.

Simulatie-log

xcelium> run
Time scale of (tb) is 1ns / 1ps
Time scale of (tb.m_alu) is 1ns / 1ps
Time scale of (tb.m_des) is 1ns / 10ps
xmsim: *W,RNQUIE: Simulation is complete.

Bestanden wisselen kan timescale veranderen

De volgorde van inclusie van bestanden speelt een belangrijke rol in herdefinitie van timescale-directives, wat duidelijk is in het onderstaande voorbeeld.

// main.v
\`timescale 1ns/1ps
module tb;
  des m_des();
  alu m_alu();
  initial begin
    $printtimescale(tb);
    $printtimescale(tb.m_alu);
    $printtimescale(tb.m_des);
  end
endmodule
// LET OP! Volgorde van inclusie omgewisseld
\`include "file_des.v"
\`include "file_alu.v"

// file_alu.v
module alu;
endmodule

// file_des.v
\`timescale 1ns/10ps
module des;
endmodule

Zie dat de module alu nu een timescale van 1ns/10ps krijgt.

Simulatie-log

xcelium> run
Time scale of (tb) is 1ns / 1ps
Time scale of (tb.m_alu) is 1ns / 10ps
Time scale of (tb.m_des) is 1ns / 10ps
xmsim: *W,RNQUIE: Simulation is complete.

Dit is een van de redenen om een timescale-directive bovenaan bestanden te plaatsen zodat alle modules in dat bestand de correcte timescale aannemen ongeacht bestandsinclusie.

Deze aanpak kan het echter moeilijk maken om te compileren met een andere timescale-precisie (waarde na de schuine streep) zonder elk bestand aan te passen. Veel compilers en simulators bieden ook een optie om standaard timescale-waarden te overschrijven die op alle modules toegepast worden.

Verilog

  1. Verilog beheersen: Complete tutorial voor digitale schakelingontwerp
  2. Verilog concatenatie beheersen: Een praktische gids
  3. Verilog-toewijzingen begrijpen: types, syntax en best practices
  4. Verilog Blocking vs. Non-Blocking: belangrijkste verschillen uitgelegd
  5. Verilog-functies beheersen voor efficiënt RTL-ontwerp
  6. Verilog Tasks begrijpen: Functions vs Tasks, Syntax en Gebruik
  7. Verilog Hiërarchische Referentie Scope: Naamconflicten in Modules en Blokken vermijden
  8. Verilog Clock Generator: Ontwerp & Implementatie Gids
  9. Verilog Math Functions beheersen voor efficiënt Hardware-ontwerp
  10. Verilog $timeformat beheersen: Precisie en Weergave-controle
  11. Verilog File I/O onder de knie: Openen, Lezen, Schrijven en Sluiten