This file is indexed.

/usr/include/gpsim/p18x.h is in gpsim-dev 0.29.0-2+b2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
/*
   Copyright (C) 1998 T. Scott Dattalo
   Copyright (C) 2010,2015 Roy R Rankin


This file is part of the libgpsim library of gpsim

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see 
<http://www.gnu.org/licenses/lgpl-2.1.html>.
*/

#ifndef __P18X_H__
#define __P18X_H__

#include "16bit-processors.h"
#include "eeprom.h"
#include "psp.h"
#include "pir.h"
#include "comparator.h"
#include "spp.h"
#include "ctmu.h"

class PicPortRegister;
class PicTrisRegister;
class PicLatchRegister;
class ADCON0_V2;
class ADCON1_V2;
class ADCON2_V2;

class P18C2x2 : public _16bit_compat_adc
{
 public:

  P18C2x2(const char *_name=0, const char *desc=0);

  void create();

  virtual PROCESSOR_TYPE isa(){return _P18Cxx2_;};
  virtual PROCESSOR_TYPE base_isa(){return _PIC18_PROCESSOR_;};
  virtual void create_symbols();

  virtual unsigned int program_memory_size() const { return 0x400; };
  virtual unsigned int IdentMemorySize() const { return 2; }    // only two words on 18C

  virtual void create_iopin_map();

};

class P18C242 : public P18C2x2
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18C242_;};
  P18C242(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();

  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int last_actual_register () const { return 0x01FF;};

};

class P18C252 : public P18C242
{
 public:

  virtual PROCESSOR_TYPE isa(){return _P18C252_;};
  P18C252(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();

  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int last_actual_register () const { return 0x05FF;};


};

/*********************************************************************
 *  class definitions for the 18C4x2 family
 */

//class P18C4x2 : public _16bit_processor
class P18C4x2 : public _16bit_compat_adc
{
 public:


  PicPSP_PortRegister  *m_portd;
  PicTrisRegister  *m_trisd;
  PicLatchRegister *m_latd;

  PicPortRegister  *m_porte;
  PicPSP_TrisRegister  *m_trise;
  PicLatchRegister *m_late;

  PSP               psp;

  P18C4x2(const char *_name=0, const char *desc=0);
  ~P18C4x2();

  void create();

  virtual PROCESSOR_TYPE isa(){return _P18Cxx2_;};
  virtual PROCESSOR_TYPE base_isa(){return _PIC18_PROCESSOR_;};
  virtual void create_symbols();

  virtual unsigned int program_memory_size() const { return 0x400; };
  virtual unsigned int IdentMemorySize() const { return 2; }    // only two words on 18C

  virtual void create_sfr_map();
  virtual void create_iopin_map();

};


class P18C442 : public P18C4x2
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18C442_;};
  P18C442(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int eeprom_memory_size() const { return 256; };
  virtual unsigned int last_actual_register () const { return 0x01FF;};

};


class P18C452 : public P18C442
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18C452_;};
  P18C452(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int last_actual_register () const { return 0x05FF;};

};

class P18F242 : public P18C242
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F242_;};
  P18F242(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int eeprom_memory_size() const { return 256; };
  virtual unsigned int IdentMemorySize() const { return 4; }

  virtual void set_eeprom(EEPROM *ep) {
    // Use set_eeprom_pir as the 18Fxxx devices use an EEPROM with PIR
   assert(0);
  }
  virtual void set_eeprom_pir(EEPROM_PIR *ep) { eeprom = ep; }
  virtual EEPROM_PIR *get_eeprom() { return ((EEPROM_PIR *)eeprom); }

};

class P18F252 : public P18F242
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F252_;};
  P18F252(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int last_actual_register () const { return 0x05FF;};

};

class P18F442 : public P18C442
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F442_;};
  P18F442(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int IdentMemorySize() const { return 4; }

  virtual void set_eeprom(EEPROM *ep) {
    // Use set_eeprom_pir as the 18Fxxx devices use an EEPROM with PIR
   assert(0);
  }
  virtual void set_eeprom_pir(EEPROM_PIR *ep) { eeprom = ep; }
  virtual EEPROM_PIR *get_eeprom() { return ((EEPROM_PIR *)eeprom); }

};

//
// The P18F248 is the same as the P18F242 except it has CAN, one fewer
// CCP module and a 5/10 ADC.  For now just assume it is identical.
class P18F248 : public P18F242
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F248_;};
  P18F248(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
};
 
//
// The P18F448 is the same as the P18F442 except it has CAN, one fewer
// CCP module and a 5/10 ADC.  For now just assume it is identical.
class P18F448 : public P18F442
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F448_;};
  P18F448(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();
};
 

class P18F452 : public P18F442
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F452_;};
  P18F452(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();

  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int last_actual_register () const { return 0x05FF;};
};




class P18F1220 : public  _16bit_v2_adc
{
 public:
  OSCTUNE      osctune;
  ECCPAS        eccpas;
  PWM1CON       pwm1con;

  virtual PROCESSOR_TYPE base_isa(){return _PIC18_PROCESSOR_;};
  virtual PROCESSOR_TYPE isa(){return _P18F1220_;};
  P18F1220(const char *_name=0, const char *desc=0);
  ~P18F1220();


  static Processor *construct(const char *name);
  void create();
  virtual void create_iopin_map();
  virtual unsigned int program_memory_size() const { return 0x1000; };
  virtual unsigned int eeprom_memory_size() const { return 256; };
  virtual void osc_mode(unsigned int value);
  virtual unsigned int last_actual_register () const { return 0x00FF;};

  // Strip down from base class
  virtual bool HasPortC(void) { return false; };
  virtual bool HasCCP2(void) { return false; };
  
  virtual void set_eeprom(EEPROM *ep) {
    // Use set_eeprom_pir as the 18Fxxx devices use an EEPROM with PIR
   assert(0);
  }
  virtual void set_eeprom_pir(EEPROM_PIR *ep) { eeprom = ep; }
  virtual EEPROM_PIR *get_eeprom() { return ((EEPROM_PIR *)eeprom); }
  virtual unsigned int get_device_id() { return (0x07 << 8)|(0x7 <<5); }
};


class P18F1320 : public P18F1220
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F1320_;};
  P18F1320(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);
  void create();

  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int get_device_id() { return (0x07 << 8)|(0x6 <<5); }

};



class P18F2x21 : public _16bit_v2_adc
{
 public:

  PicPortRegister  *m_porte;
  PicPSP_TrisRegister  *m_trise;
  PicLatchRegister *m_late;

  ECCPAS        eccpas;
  PWM1CON       pwm1con;

  OSCTUNE      osctune;
  ComparatorModule comparator;

  P18F2x21(const char *_name=0, const char *desc=0);
  ~P18F2x21();

  void create();

  virtual PROCESSOR_TYPE isa(){return _P18Cxx2_;};
  virtual PROCESSOR_TYPE base_isa(){return _PIC18_PROCESSOR_;};
  virtual void create_symbols();

  virtual unsigned int program_memory_size() const { return 0x400; };
  virtual unsigned int eeprom_memory_size() const { return 0x100; };

// Setting the correct register memory size breaks things
//  virtual unsigned int register_memory_size () const { return 0x200;};
  virtual unsigned int last_actual_register () const { return 0x01FF;};

  virtual void create_iopin_map();
  virtual void create_sfr_map();


  virtual void set_eeprom(EEPROM *ep) {
    // Use set_eeprom_pir as the 18Fxxx devices use an EEPROM with PIR
   assert(0);
  }
  virtual void set_eeprom_pir(EEPROM_PIR *ep) { eeprom = ep; }
  virtual EEPROM_PIR *get_eeprom() { return ((EEPROM_PIR *)eeprom); }

  virtual void osc_mode(unsigned int value);
};


class P18F2221 : public P18F2x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F2221_;};
  P18F2221(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x800; };
  virtual unsigned int get_device_id() { return (0x21 << 8)|(0x3 <<5); }
};

class P18F2321 : public P18F2x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F2321_;};
  P18F2321(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x1000; };
  virtual unsigned int get_device_id() { return (0x21 << 8)|(0x1 <<5); }
};

class P18F2420 : public P18F2x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F2420_;};
  P18F2420(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int eeprom_memory_size() const { return 256; };
  virtual unsigned int last_actual_register () const { return 0x02FF;};
  virtual unsigned int get_device_id() { return (0x0c << 8)|(0x6 <<5); }
};

class P18F2455 : public P18F2x21
{
 public:
  sfr_register ufrml, ufrmh, uir,  uie,  ueir,  ueie,  ustat,  ucon,
               uaddr, ucfg,  uep0, uep1, uep2,  uep3,  uep4,   uep5,
               uep6,  uep7,  uep8, uep9, uep10, uep11, uep12,  uep13,
               uep14,  uep15;

  virtual PROCESSOR_TYPE isa(){return _P18F2455_;};
  P18F2455(const char *_name=0, const char *desc=0);
  ~P18F2455();
  static Processor *construct(const char *name);
  void create_sfr_map();

  virtual unsigned int access_gprs() { return 0x60; };  // USB peripheral moves access split
  virtual unsigned int program_memory_size() const { return 0x3000; };
  virtual unsigned int last_actual_register () const { return 0x07FF;};
  virtual unsigned int get_device_id() { return (0x12 << 8)|(0x3 <<5); }

};

class P18F2550 : public P18F2x21
{
 public:
  sfr_register ufrml, ufrmh, uir,  uie,  ueir,  ueie,  ustat,  ucon,
               uaddr, ucfg,  uep0, uep1, uep2,  uep3,  uep4,   uep5,
               uep6,  uep7,  uep8, uep9, uep10, uep11, uep12,  uep13,
               uep14,  uep15;

  virtual PROCESSOR_TYPE isa(){return _P18F2550_;};
  P18F2550(const char *_name=0, const char *desc=0);
  ~P18F2550();
  static Processor *construct(const char *name);
  void create_sfr_map();

  virtual unsigned int access_gprs() { return 0x60; };  // USB peripheral moves access split
  virtual unsigned int program_memory_size() const { return 16384; };
  virtual unsigned int last_actual_register () const { return 0x07FF;};
  virtual unsigned int get_device_id() { return (0x12 << 8)|(0x2 <<5); }

};

class P18F2520 : public P18F2x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F2520_;};
  P18F2520(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int last_actual_register () const { return 0x05FF;};
  virtual unsigned int get_device_id() { return (0x0c << 8)|(0x4 <<5); }
};

class P18F2620 : public P18F2x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F2620_;};
  P18F2620(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x8000; };
  virtual unsigned int last_actual_register () const { return 0x0F7F;};
  virtual unsigned int get_device_id() { return (0x0c << 8)|(0x4 <<5); }
};

class RegZero : public Register
{
public:
   RegZero(Module *_cpu, const char *_name=0, const char *desc=0): 
	Register(_cpu, _name, desc) {}
   virtual void put(unsigned int new_value) { value.put(0);}
   virtual void put_value(unsigned int new_value) { value.put(0);}
};

class P18F26K22 : public _16bit_processor
{
 public:

  PicPortRegister  *m_porte;
  PicTrisRegister  *m_trise;
  PicLatchRegister *m_late;


  OSCCON_HS	osccon;
  ADCON0_V2	adcon0;
  ADCON1_2B	adcon1;
  ADCON2_V2	adcon2;
  FVRCON_V2	vrefcon0;
  DACCON0_V2	vrefcon1;
  DACCON1	vrefcon2;
  ECCPAS        eccp1as;
  ECCPAS        eccp2as;
  ECCPAS        eccp3as;
  PWM1CON       pwm1con;
  PWM1CON       pwm2con;
  PWM1CON       pwm3con;
  OSCTUNE      osctune;

  T1GCON	t1gcon;
  T5CON		*t3con2;
  T1GCON 	t3gcon;
  TMRL		tmr5l;
  TMRH		tmr5h;
  T5CON		*t5con;
  T1GCON	t5gcon;
  T2CON        t4con;
  PR2          pr4;
  TMR2         tmr4;
  T2CON        t6con;
  PR2          pr6;
  TMR2         tmr6;
  PIR3v3       pir3;
  PIE          pie3;
  PIR4v1       pir4;
  PIE          pie4;
  PIR5v1       pir5;
  PIE          pie5;
  sfr_register ipr3;
  sfr_register ipr4;
  sfr_register ipr5;
  CCPCON       ccp3con;
  CCPRL        ccpr3l;
  CCPRH        ccpr3h;
  CCPCON       ccp4con;
  CCPRL        ccpr4l;
  CCPRH        ccpr4h;
  CCPCON       ccp5con;
  CCPRL        ccpr5l;
  CCPRH        ccpr5h;
  USART_MODULE         usart2;
  ComparatorModule2 comparator;
  sfr_register pmd0;
  sfr_register pmd1;
  sfr_register pmd2;
  ANSEL_2B	ansela;
  ANSEL_2B	anselb;
  ANSEL_2B	anselc;
  IOC		slrcon;  // using IOC for it's mask this register is a NOP in gpsim
  CCPTMRS	ccptmrs;
  PSTRCON	pstr1con;
  PSTRCON	pstr2con;
  PSTRCON	pstr3con;
  SR_MODULE	sr_module;
  SSP1_MODULE   ssp1;
  SSP1_MODULE   ssp2;
  CTMU		ctmu;
  HLVDCON	hlvdcon;

  WPU		*wpub;
  IOC		*iocb;
  virtual bool HasCCP2(void) { return false; }; // at wrong address
  virtual bool MovedReg() { return true;}
  virtual PROCESSOR_TYPE isa(){return _P18F26K22_;};
  P18F26K22(const char *_name=0, const char *desc=0);
  ~P18F26K22();
  static Processor *construct(const char *name);

  virtual PROCESSOR_TYPE base_isa(){return _PIC18_PROCESSOR_;};
  virtual unsigned int access_gprs() { return 0x60; };
  virtual unsigned int program_memory_size() const { return 0x8000; };
  virtual unsigned int last_actual_register () const { return 0x0F37;};
  virtual unsigned int eeprom_memory_size() const { return 1024; };
  virtual void create_iopin_map();
  virtual void create_sfr_map();
  virtual void osc_mode(unsigned int value);
  virtual void set_config3h(gint64 x);
  virtual string string_config3h(gint64 x)
	{return string("fix string_config3h");}
  virtual unsigned int get_device_id() { return (0x54 << 8)|(0x3 <<5); }


  void create();
  virtual void update_vdd();


  virtual void set_eeprom(EEPROM *ep) {
    // Use set_eeprom_pir as the 18Fxxx devices use an EEPROM with PIR
   assert(0);
  }
  virtual void set_eeprom_pir(EEPROM_PIR *ep) { eeprom = ep; }
  virtual EEPROM_PIR *get_eeprom() { return ((EEPROM_PIR *)eeprom); }
};



class P18F4x21 : public P18F2x21
{
 public:

  PicPSP_PortRegister  *m_portd;
  PicTrisRegister  *m_trisd;
  PicLatchRegister *m_latd;


  P18F4x21(const char *_name=0, const char *desc=0);
  ~P18F4x21();

  void create();

  virtual void create_symbols();

  virtual void create_iopin_map();
  virtual void create_sfr_map();

};


class P18F4221 : public P18F4x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F4221_;};
  P18F4221(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x800; };
  virtual unsigned int get_device_id() { return (0x21 << 8)|(0x2 <<5); }
};

class P18F4321 : public P18F4x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F4321_;};
  P18F4321(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x1000; };
  virtual unsigned int get_device_id() { return (0x21 << 8)|(0x0 <<5); }
};

class P18F4420 : public P18F4x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F4420_;};
  P18F4420(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x2000; };
  virtual unsigned int get_device_id() { return (0x0c << 8)|(0x2 <<5); }
};

class P18F4455 : public P18F4x21
{
 public:
  sfr_register ufrml, ufrmh, uir,  uie,  ueir,  ueie,  ustat,  ucon,
               uaddr, ucfg,  uep0, uep1, uep2,  uep3,  uep4,   uep5,
               uep6,  uep7,  uep8, uep9, uep10, uep11, uep12,  uep13,
               uep14,  uep15;

  SPP		spp;
  SPPCON 	sppcon;
  SPPCFG 	sppcfg;
  SPPEPS 	sppeps;
  SPPDATA 	sppdata;

  virtual PROCESSOR_TYPE isa(){return _P18F4455_;};
  P18F4455(const char *_name=0, const char *desc=0);
  ~P18F4455();
  static Processor *construct(const char *name);
  void create();

  virtual unsigned int access_gprs() { return 0x60; };  // USB peripheral moves access split
  virtual unsigned int program_memory_size() const { return 0x3000; };
  virtual unsigned int last_actual_register () const { return 0x07FF;};
  virtual unsigned int get_device_id() { return (0x12 << 8)|(0x1 <<5); }

};

class P18F4550 : public P18F4x21
{
 public:
  sfr_register ufrml, ufrmh, uir,  uie,  ueir,  ueie,  ustat,  ucon,
               uaddr, ucfg,  uep0, uep1, uep2,  uep3,  uep4,   uep5,
               uep6,  uep7,  uep8, uep9, uep10, uep11, uep12,  uep13,
               uep14,  uep15;

  SPP		spp;
  SPPCON 	sppcon;
  SPPCFG 	sppcfg;
  SPPEPS 	sppeps;
  SPPDATA 	sppdata;

  virtual PROCESSOR_TYPE isa(){return _P18F4550_;};
  P18F4550(const char *_name=0, const char *desc=0);
  ~P18F4550();
  static Processor *construct(const char *name);
  void create();

  virtual unsigned int access_gprs() { return 0x60; };  // USB peripheral moves access split
  virtual unsigned int program_memory_size() const { return 16384; };
  virtual unsigned int last_actual_register () const { return 0x07FF;};
  virtual unsigned int get_device_id() { return (0x12 << 8)|(0x0 <<5); }

};

class P18F4520 : public P18F4x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F4520_;};
  P18F4520(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int last_actual_register () const { return 0x05FF;};
  virtual unsigned int get_device_id() { return (0x0c << 8)|(0x0 <<5); }
};





/***
PIC18F4620
Not implemented: 
  OSCFIF bit in peripheral interrupt register 2 (PIR2v2 pir2)(And Enable Bit)
  
***/
class P18F4620 : public P18F4x21
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F4620_;};
  P18F4620(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

  virtual unsigned int program_memory_size() const { return 0x8000; };
  virtual unsigned int eeprom_memory_size() const { return 1024; };
  virtual unsigned int last_actual_register () const { return 0x0F7F;};
  virtual unsigned int get_device_id() { return (0x0c << 8)|(0x4 <<5); }
};



class P18F6x20 : public _16bit_v2_adc
{
 public:

  PicPSP_PortRegister  *m_portd;
  PicTrisRegister  *m_trisd;
  PicLatchRegister *m_latd;

  PicPortRegister  *m_porte;
  PicTrisRegister  *m_trise;
  PicLatchRegister *m_late;

  PicPortRegister  *m_portf;
  PicTrisRegister  *m_trisf;
  PicLatchRegister *m_latf;

  PicPortRegister  *m_portg;
  PicTrisRegister  *m_trisg;
  PicLatchRegister *m_latg;

  PSP               psp;
  PSPCON	    *pspcon;

//  ECCPAS        eccpas;
//  PWM1CON       pwm1con;
  T2CON        t4con;
  PR2          pr4;
  TMR2         tmr4;
  PIR3v1       pir3;
  PIE          pie3;
  sfr_register ipr3;
  CCPCON       ccp3con;
  CCPRL        ccpr3l;
  CCPRH        ccpr3h;
  CCPCON       ccp4con;
  CCPRL        ccpr4l;
  CCPRH        ccpr4h;
  CCPCON       ccp5con;
  CCPRL        ccpr5l;
  CCPRH        ccpr5h;
  USART_MODULE         usart2;

//  OSCTUNE      osctune;
  ComparatorModule comparator;

  P18F6x20(const char *_name=0, const char *desc=0);
  ~P18F6x20();

  void create();

  virtual PROCESSOR_TYPE isa(){return _P18Cxx2_;};
  virtual PROCESSOR_TYPE base_isa(){return _PIC18_PROCESSOR_;};
  virtual unsigned int access_gprs() { return 0x60; };
  virtual void create_symbols();

  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int eeprom_memory_size() const { return 1024; };

// Setting the correct register memory size breaks things
//  virtual unsigned int register_memory_size () const { return 0x800;};
  virtual unsigned int last_actual_register () const { return 0x07FF;};

  virtual void create_iopin_map();
  virtual void create_sfr_map();


  virtual void set_eeprom(EEPROM *ep) {
    // Use set_eeprom_pir as the 18Fxxx devices use an EEPROM with PIR
   assert(0);
  }
  virtual void set_eeprom_pir(EEPROM_PIR *ep) { eeprom = ep; }
  virtual EEPROM_PIR *get_eeprom() { return ((EEPROM_PIR *)eeprom); }
};


class P18F6520 : public P18F6x20
{
 public:
  virtual PROCESSOR_TYPE isa(){return _P18F6520_;};
  P18F6520(const char *_name=0, const char *desc=0);
  static Processor *construct(const char *name);

//  virtual unsigned int program_memory_size() const { return 0x4000; };
  virtual unsigned int bugs() { return BUG_DAW; };
  virtual unsigned int get_device_id() { return (0x0b << 8)|(0x1 <<5); }
};

#endif