Skip to content

Commit 2667f1b

Browse files
committedMay 22, 2017
Began work on DAC-from-counter support. See #32
1 parent e2fb1f1 commit 2667f1b

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed
 

‎doc/gp4-hdl.tex

+9-5
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,9 @@ \subsection{Counters}
806806
\namestyle{Yosys} provides limited inference capability for counters which match the capabilities of the hard macro counters
807807
(\tokenref{GP\_COUNT8}{gp-count8} and \tokenref{GP\_COUNT14}{gp-count14}) in the device.
808808

809-
Some hard macro capabilities (most notably input dividers) are not yet supported for inference; if these capabilities
810-
are required then use explicit primitive instantiation. Future software releases will expand the set of counter
811-
features which may be inferred.
809+
Some hard macro capabilities (most notably input dividers and parallel output to DCMP/DAC blocks) are not yet supported
810+
for inference; if these capabilities are required then use explicit primitive instantiation. Future software releases
811+
will expand the set of counter features which may be inferred.
812812

813813
\subsubsection{Inference Requirements}
814814

@@ -819,7 +819,8 @@ \subsubsection{Inference Requirements}
819819
\item Count down only
820820
\item Be initialized to the same (maximum) value by both underflow and by power-on reset
821821
\item Have either no reset, or a positive level triggered reset to zero
822-
\item Not have any logic use the internal counter register. Only the ``underflow" signal may be used by surrounding logic.
822+
\item Not have any logic use the internal counter register. Only the ``underflow" signal may be used by surrounding
823+
logic.
823824
\end{itemize}
824825

825826
\subsubsection{Counter Related Constraints}
@@ -1736,13 +1737,16 @@ \subsubsection{Introduction}
17361737
This primitive corresponds to an 8-bit digital to analog converter. The DAC operates combinatorially and does not
17371738
require a clock.
17381739

1740+
Note that the DAC's input uses dedicated routing and not a general fabric connection; see the device datasheet for
1741+
information on legal connections.
1742+
17391743
\subsubsection{Port Descriptions}
17401744

17411745
\begin{tabularx}{\textwidth}{lllX}
17421746
\thinhline
17431747
\whenstyle{Port} & \whenstyle{Type} & \whenstyle{Width} & \whenstyle{Function} \\
17441748
\thickhline
1745-
\tokenstyle{DIN} & Input & 8 & Input data. Must be connected to an 8-bit constant value for now. \\
1749+
\tokenstyle{DIN} & Input & 8 & Input data. \\
17461750
\thinhline
17471751
\tokenstyle{VREF} & Input & 1 & Analog reference voltage from \tokenref{GP\_VREF}{gp-vref}. \\
17481752
\thinhline

‎src/gp4par/make_graphs.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,17 @@ void MakeDeviceEdges(Greenpak4Device* device)
12591259
gnd->AddEdge("OUT", dac, "DIN[7]");
12601260
}
12611261

1262-
//TODO: Direct inputs from counters
1262+
//Add inputs from counters to each DAC (shared with DCMP mux)
1263+
for(size_t j=0; j<device->GetDACCount(); j++)
1264+
{
1265+
auto dac = device->GetDAC(j)->GetPARNode();
1266+
for(int i=0; i<8; i++)
1267+
{
1268+
snprintf(inname, sizeof(inname), "DIN[%d]", i);
1269+
cnodes[9]->AddEdge("POUT", dac, inname);
1270+
cnodes[2]->AddEdge("POUT", dac, inname);
1271+
}
1272+
}
12631273

12641274
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12651275
// OUTPUTS FROM DAC

‎src/greenpak4/Greenpak4DAC.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ bool Greenpak4DAC::Save(bool* bitstream)
185185
if(m_device->GetPart() == Greenpak4Device::GREENPAK4_SLG46140)
186186
LogError("Greenpak4DAC: not implemented for 46140 yet\n");
187187

188-
//Input selector (hard code to "register" for now)
188+
//Input selector
189189
//WTF, the config is flipped from DAC0 to DAC1??? (see SLG46620V table 40)
190190
//This also applies to the SLG46140 (see SLG46140 table 28).
191191
if(m_dacnum == 0)
192-
bitstream[m_cbaseInsel] = false;
192+
bitstream[m_cbaseInsel] = !dinPower;
193193
else
194-
bitstream[m_cbaseInsel] = true;
194+
bitstream[m_cbaseInsel] = dinPower;
195195

196196
//Constant input voltage
197197
if(dinPower)

‎tests/greenpak4/slg46620v/Dac.v

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************************************************************************
2-
* Copyright (C) 2016 Andrew Zonenberg and contributors *
2+
* Copyright (C) 2017 Andrew Zonenberg and contributors *
33
* *
44
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General *
55
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) *
@@ -98,6 +98,8 @@ module Dac(bg_ok, vout, vout2, wave_sync);
9898

9999
localparam COUNT_MAX = 255;
100100

101+
//TODO: support for inference of counters with parallel output
102+
/*
101103
(* LOC = "COUNT8_6" *)
102104
(* COUNT_EXTRACT = "FORCE" *)
103105
reg[7:0] count = COUNT_MAX;
@@ -110,14 +112,28 @@ module Dac(bg_ok, vout, vout2, wave_sync);
110112
111113
//Counter overflow signal to LED
112114
assign wave_sync = (count == 0);
115+
*/
116+
117+
//Explicitly instantiated counter b/c we don't yet have inference support when using POUT
118+
wire[7:0] count_pout;
119+
GP_COUNT8 #(
120+
.CLKIN_DIVIDE(1),
121+
.COUNT_TO(COUNT_MAX),
122+
.RESET_MODE("RISING")
123+
) cnt (
124+
.CLK(clk_108hz),
125+
.RST(1'b0),
126+
.OUT(wave_sync),
127+
.POUT(count_pout)
128+
);
113129

114130
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115131
// DAC driving the voltage reference
116132

117133
wire vdac;
118134
(* LOC = "DAC_1" *)
119135
GP_DAC dac(
120-
.DIN(8'hff), //count
136+
.DIN(count_pout),
121137
.VOUT(vdac),
122138
.VREF(vref_1v0)
123139
);

0 commit comments

Comments
 (0)
Please sign in to comment.