2
Copyright (C) 2017 Roy R Rankin
4
This file is part of the libgpsim library of gpsim
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, see
18
<http://www.gnu.org/licenses/lgpl-2.1.html>.
20
/****************************************************************
22
* Modified 2018 by Santiago Gonzalez santigoro@gmail.com *
24
*****************************************************************/
26
// CONFIGURABLE LOGIC CELL (CLC)
31
#include "registers.h"
40
class CLCxCON : public SfrReg
43
CLCxCON(CLC *_clc, Processor *pCpu, const char *pName) :
44
SfrReg(pCpu, pName), m_clc(_clc), write_mask(0xdf)
54
class CLCxPOL : public SfrReg
57
CLCxPOL(CLC *_clc, Processor *pCpu, const char *pName ) :
58
SfrReg(pCpu, pName ), m_clc(_clc), write_mask(0x8f)
70
class CLCxSEL0 : public SfrReg
73
CLCxSEL0(CLC *_clc, Processor *pCpu, const char *pName );
83
class CLCxSEL1 : public SfrReg
86
CLCxSEL1(CLC *_clc, Processor *pCpu, const char *pName );
94
class CLCxGLS0 : public SfrReg
97
CLCxGLS0(CLC *_clc, Processor *pCpu, const char *pName ) :
98
SfrReg(pCpu, pName ), m_clc(_clc)
108
class CLCxGLS1 : public SfrReg
111
CLCxGLS1(CLC *_clc, Processor *pCpu, const char *pName ) :
112
SfrReg(pCpu, pName ), m_clc(_clc)
123
class CLCxGLS2 : public SfrReg
126
CLCxGLS2(CLC *_clc, Processor *pCpu, const char *pName ) :
127
SfrReg(pCpu, pName ), m_clc(_clc)
138
class CLCxGLS3 : public SfrReg
141
CLCxGLS3(CLC *_clc, Processor *pCpu, const char *pName ) :
142
SfrReg(pCpu, pName ), m_clc(_clc)
153
class CLCDATA : public SfrReg
156
CLCDATA(Processor *pCpu, const char *pName = 0 ) :
159
for(int i = 0; i < 4; i++)
164
void put(uint val){;}
165
void set_bit(bool bit_val, uint pos);
166
void set_clc(CLC *clc1, CLC *clc2=0, CLC *clc3=0, CLC *clc4 = 0)
178
class CLC : public apfpin
181
CLC(Processor *_cpu, uint _index, CLCDATA *_clcdata);
226
bool CLCenabled() { return clcxcon.value.get() & LCxEN; }
227
void setCLCxPin( PinModule *alt_pin );
228
void enableINxpin( int, bool );
229
virtual void setIOpin( int data, PinModule *pin );
230
virtual void D1S( int select );
231
virtual void D2S( int select );
232
virtual void D3S( int select );
233
virtual void D4S( int select );
237
void osc_out( bool level, int kind );
238
void out_pwm( bool level, int id );
239
void NCO_out( bool level );
240
void CxOUT_sync(bool output, int cm);
241
void set_clcPins(PinModule *IN0, PinModule *IN1, PinModule *_CLCx)
242
{ pinCLCxIN[0] = IN0; pinCLCxIN[1] = IN1, pinCLCx = _CLCx;}
243
void setState(char new3State, int index);
244
void releasePinSource(PinModule *pin);
245
void oeCLCx(bool on);
246
void update_clccon(uint diff);
247
void config_inputs(bool on);
248
void compute_gates();
249
void cell_function();
250
bool cell_1_in_flipflop();
251
bool cell_2_in_flipflop();
252
bool cell_sr_latch();
254
bool transparent_D_latch();
255
void lcxupdate(bool bit_val, uint pos);
256
virtual void setInterruptSource(InterruptSource * _int)
257
{ m_Interrupt = _int;}
258
void outputCLC(bool out);
278
CLCSigSource *CLCxsrc;
281
INxSignalSink *INxsink[2];
284
PinModule *pinCLCxIN[2];
287
bool CMxOUT_level[4];
290
bool lcxdT[4]; // incoming data
291
bool lcxg[4]; // Data gate output
292
InterruptSource *m_Interrupt;
300
class CLC1 : public CLC
303
CLC1( Processor* _cpu, uint _index, CLCDATA* _clcdata );
305
virtual void D1S(int select);
306
virtual void D2S(int select);
307
virtual void D3S(int select);
308
virtual void D4S(int select);
311
void setDxsData( int select, int i );
314
// RC clock 600KHz used with ADC, CLC
315
class OSC_SIM : public TriggerObject
318
OSC_SIM( double _freq, int _data_in , Processor* cpu );
320
void start_osc_sim(bool on);
322
void set_clc(CLC *clc1, CLC *clc2=0, CLC *clc3=0, CLC *clc4 = 0)
324
m_clc[0] = clc1; m_clc[1] = clc2; m_clc[2] = clc3; m_clc[3] = clc4;
335
uint64_t future_cycle;
336
int64_t adjust_cycles;